package org.qfedu.edu.auto;

import org.junit.Before;
import org.qfedu.edu.impl.TokenService;
import org.qfedu.edu.properties.TokenProperties;
import org.qfedu.edu.service.ITokenService;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author xiaobobo
 * @title: TokenServiceAutoConfiguration
 * @projectName seckill-fy-2401-parent
 * @description: 自动配置
 * @date 2024/11/4  14:24
 */
@SpringBootConfiguration
@EnableConfigurationProperties({TokenProperties.class})
public class TokenServiceAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public ITokenService tokenService(TokenProperties tokenProperties) {
        ITokenService tokenService = new TokenService(tokenProperties.getExpire(), tokenProperties.getSign());
        return tokenService;
    }
}
